<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: Critical sections</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__sys__prot.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a>  </div>
  <div class="headertitle">
<div class="title">Critical sections<div class="ingroups"><a class="el" href="group__lwip.html">lwIP</a> &raquo; <a class="el" href="group__sys__layer.html">Porting (system abstraction layer)</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga945395fa326214fc9736487242710a90"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sys__prot.html#ga945395fa326214fc9736487242710a90">SYS_ARCH_DECL_PROTECT</a>(lev)&#160;&#160;&#160;sys_prot_t lev</td></tr>
<tr class="separator:ga945395fa326214fc9736487242710a90"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3d0e48feafd378e9c26c64567ecd8bab"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sys__prot.html#ga3d0e48feafd378e9c26c64567ecd8bab">SYS_ARCH_PROTECT</a>(lev)&#160;&#160;&#160;lev = sys_arch_protect()</td></tr>
<tr class="separator:ga3d0e48feafd378e9c26c64567ecd8bab"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2f48e97047945642ddeb27e65bf4ffe2"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sys__prot.html#ga2f48e97047945642ddeb27e65bf4ffe2">SYS_ARCH_UNPROTECT</a>(lev)&#160;&#160;&#160;sys_arch_unprotect(lev)</td></tr>
<tr class="separator:ga2f48e97047945642ddeb27e65bf4ffe2"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Used to protect short regions of code against concurrent access.</p><ul>
<li>Your system is a bare-metal system (probably with an RTOS) and interrupts are under your control: Implement this as LockInterrupts() / UnlockInterrupts()</li>
<li>Your system uses an RTOS with deferred interrupt handling from a worker thread: Implement as a global mutex or lock/unlock scheduler</li>
<li>Your system uses a high-level OS with e.g. POSIX signals: Implement as a global mutex </li>
</ul>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ga945395fa326214fc9736487242710a90"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga945395fa326214fc9736487242710a90">&#9670;&nbsp;</a></span>SYS_ARCH_DECL_PROTECT</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SYS_ARCH_DECL_PROTECT</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">lev</td><td>)</td>
          <td>&#160;&#160;&#160;sys_prot_t lev</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>SYS_LIGHTWEIGHT_PROT define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection for certain critical regions during buffer allocation, deallocation and memory allocation and deallocation.</p>
<p>SYS_ARCH_DECL_PROTECT declare a protection variable. This macro will default to defining a variable of type sys_prot_t. If a particular port needs a different implementation, then this macro may be defined in sys_arch.h. </p>

</div>
</div>
<a id="ga3d0e48feafd378e9c26c64567ecd8bab"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3d0e48feafd378e9c26c64567ecd8bab">&#9670;&nbsp;</a></span>SYS_ARCH_PROTECT</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SYS_ARCH_PROTECT</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">lev</td><td>)</td>
          <td>&#160;&#160;&#160;lev = sys_arch_protect()</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>SYS_ARCH_PROTECT Perform a "fast" protect. This could be implemented by disabling interrupts for an embedded system or by using a semaphore or mutex. The implementation should allow calling SYS_ARCH_PROTECT when already protected. The old protection level is returned in the variable "lev". This macro will default to calling the sys_arch_protect() function which should be implemented in sys_arch.c. If a particular port needs a different implementation, then this macro may be defined in sys_arch.h </p>

</div>
</div>
<a id="ga2f48e97047945642ddeb27e65bf4ffe2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2f48e97047945642ddeb27e65bf4ffe2">&#9670;&nbsp;</a></span>SYS_ARCH_UNPROTECT</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SYS_ARCH_UNPROTECT</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">lev</td><td>)</td>
          <td>&#160;&#160;&#160;sys_arch_unprotect(lev)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>SYS_ARCH_UNPROTECT Perform a "fast" set of the protection level to "lev". This could be implemented by setting the interrupt level to "lev" within the MACRO or by using a semaphore or mutex. This macro will default to calling the sys_arch_unprotect() function which should be implemented in sys_arch.c. If a particular port needs a different implementation, then this macro may be defined in sys_arch.h </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
